<?php

/*

  Action	$4

  +1 Buy, +$1
  All cards (including cards in players hands) cost $1 less this turn, but not less than $0.

 */

class Bridge extends Card implements iAction, iKingdom, iInfluence, iIntrigue {

    public function __construct() {
        parent::__construct("Bridge", 4);
        $this->undoPlay = false;
        $this->undoBuy = true;
    }

    public function getDescription() {
        return array(
            "+1 Buy",
            "+$1",
            "All cards (including cards in players hands) cost $1 less this turn, but not less than $0.");
    }
    
    public function play(Game $game, $isRealCard) {
        $game->addMoney(new Price(1));
        $game->addBuys(1);
         ScreenDisplay::addScreenMessage($game, true, "get +1$", "gets +1$");
        $game->pushCardToInfluence($this);
        $this->influence($game);
        
        $game->cardActionFinished();
        return true;
    }


    public function influence(Game $game) {
        $names = $game->getPlayersNames();
        foreach ($names as $name) {
            $cards = $game->getAllCards($name);
            foreach ($cards as $card) {
                $price = $card->getPrice($game);
                $new_price = $price->add(-1);
                $card->setPrice($new_price);
            }
        }
        
        $boardCards = $game->getAllBoardIncludingEmptyPiles(true);
        foreach ($boardCards as $card) {
            $price = $card->getPrice($game);
            $new_price = $price->add(-1);
            $card->setPrice($new_price);
        }
        
        $trashCards = $game->getTrash();
        foreach ($trashCards as $card) {
            $price = $card->getPrice($game);
            $new_price = $price->add(-1);
            $card->setPrice($new_price);
        }

        return true;
    }

}
?>